# 路由类定义

from public import BaseHandler, SQLDealHandler
from dataBase.operation import operation

data = {    # 测试json
    'cards': 10,
    'mediaAddr': 'bg.jpg',
    'userName': 'asd',
    'headImg':'bg.jpg',
    'userSign':'此用户没有个性签名啊啊啊',
    'cardTitle': 'Title',
    'cardSubtitle': 'subTitle',
    'cardContent': 'Hello World'
}
class DataHandler():
    def __init__(self):
        super().__init__()
        self.dbIndex = operation.dbIndex()
        self.sqlIndex = SQLDealHandler.Index()


# Index
class Index():
    # 最新
    class NEWHandlers(BaseHandler, DataHandler):
        def get(self):
            self.lastID = self.get_argument('lastID')
            self.device = self.get_argument('device')
            self.finish(self.sqlIndex.sqlToJson(self.dbIndex.getData(self.lastID, self.device, 1)))


    # 热门
    class HOTHandlers(BaseHandler, DataHandler):
        def get(self):
            self.lastID = self.get_argument('lastID')
            self.device = self.get_argument('device')
            self.finish(self.dbIndex.getData(self.lastID, self.device, 2))


    # 关于我
    class ABTMEHandlers(BaseHandler, DataHandler):
        def get(self):
            self.lastID = self.get_argument('lastID')
            self.device = self.get_argument('device')
            self.finish(self.dbIndex.getData(self.lastID, self.device, 3))
